<?php 
	namespace Admin\Controller;
	use Think\Controller;

	class OrderController extends Controller
	{
		public function index()
		{
			$order = M('order');

			//查询所有订单
			$list  = $order
				   ->join('__USER__ on __ORDER__.uid = __USER__.id')
				   ->select();
			// dump($list);
			// exit;
			$this->assign('list',$list);
			$this->display();
		}

		//编辑订单页面
		public function edit()
		{
			//接收参数
			

			// $data = I('param.');
			$order = M('order');
			$list  = $order
			
			->field('`order`.*,u.nickname')
			->join('__USER__ u on __ORDER__.uid = u.id')
			->find();
			// dump($list);
			// exit;

			$this->assign('list',$list);
			$this->display();
		}


		//修改订单状态
		public function orderUpdate()
		{

			//获取提交的数据
			$data = I('param.');
			
			//实例化订单表对象
			$order = M('order');

			//根据条件保存修改的数据
			$result = $order->save($data);

			//判断是否修改成功
			if($result !== false) {

				//重新定向查询订单方法
				$this->success('修改成功',U('Order/index'));
			}else{

				//失败跳转
				$this->error('修改失败');
			}
		}
	}